#!/bin/bash

set -e

# select table_name, col_name from information_schema.ins_columns where table_type = 'SUPER_TABLE' and col_type = 'TIMESTAMP' and db_name = 'iot_ts' and table_name='properties_g_modbus' and col_name in ('ts','_ts');

# 测试动态查询超级表的主键列

user="test"
pwd="gdiot!@#456"
db="ems_biz"

# ------------------------------------------ 封装的函数 ------------------------------------------

function execute_sql(){
    local sql=$1
    mysql -u "$user" "-p$pwd" -D "$db" -N -B -e "$sql"
}


# ------------------------------------------ 查超级表信息 ------------------------------------------

# 先查询有哪些超级表
query_retention_days="select param_value from blade_param where param_key = 'data.retention.days';"
execute_sql "$query_retention_days"

# oss util
# https://help.aliyun.com/zh/oss/developer-reference/install-ossutil?spm=a2c4g.11186623.0.0.484a4fa5dGVk1h
# 
# 配置：
# ossutil config
#
# ossutil ls oss://ems-archive-test